{include file="header.html"}
<script type="text/javascript">
$(function(){
    /*$('#add_time_from').datepicker({dateFormat: 'yy-mm-dd',changeMonth: true,changeYear: true});
    $('#add_time_to').datepicker({dateFormat: 'yy-mm-dd',changeMonth: true,changeYear: true});
	$('#effective_time_from').datepicker({dateFormat: 'yy-mm-dd',changeMonth: true,changeYear: true});
    $('#effective_time_to').datepicker({dateFormat: 'yy-mm-dd',changeMonth: true,changeYear: true});*/
	$('#valid_time').datepicker({dateFormat: 'yy-mm-dd',changeMonth: true,changeYear: true});
    $('#output_btn').bind('click',function(){
        var $hidden_input=$('<input type="hidden" id="out_hid_input" name="isexport" value="1" />');
		$("input[name='act']").val("export");
        $('#output_form').prepend($hidden_input).submit();
		$("input[name='act']").val("index");
        $('#out_hid_input').remove();
    });
	
	/* 全选 */
    $('.checkall_s').click(function() {
		var if_check = $(this).attr('checked');
        $('.checkitem').each(function(){
            if(!this.disabled)
            {
                $(this).attr('checked', if_check);
            }
        });
        $('.checkall_s').attr('checked', if_check);
    });

    /* 批量操作按钮 */
    if ($('#batchAction').length == 1) {
        $('.batchButton_s').click(function() {
            /* 是否有选择 */
            if ($('.checkitem:checked').length == 0) { //没有选择
                return false;
            }
            /* 运行presubmit */
            if ($(this).attr('presubmit')) {
                if (!eval($(this).attr('presubmit'))) {
                    return false;
                }
            }
            /* 获取选中的项 */
            var items = '';
            $('.checkitem:checked').each(function() {
                items += this.value + ',';
            });
            items = items.substr(0, (items.length - 1));
            /* 将选中的项通过GET方式提交给指定的URI */
            var uri = $(this).attr('uri');
			var id = $(this).attr('id');
			if(id == 'sub_valid_time'){
				var valid_time=$("#valid_time").val();
				if(valid_time == ''){
					alert("请选择卡的有效日期");
					return false;
					}
				uri += "&valid_time="+valid_time;
			}
            window.location = uri + '&' + $(this).attr('name') + '=' + items;
        });
    }
});
</script>
<div id="rightTop">
  <p>{$lang.pointcard_manage}</p>
  <ul class="subnav">
    <li><span>{$lang.manage}</span></li>
    <li><a class="btn1" href="index.php?app=pointcard&amp;act=add">添加卡</a></li>
    <li><a  href="javascript:;" class="btn1" id="output_btn" >导出</a></li>
  </ul>
</div>
<div class="mrightTop">
  <div class="fontl">
    <form method="get" id="output_form">
      <div class="left">
        <input type="hidden" name="app" value="pointcard" />
        <input type="hidden" name="act" value="index" />
        {$lang.goods_sn}:
        <input class="infoTableInput2" type="text" name="card_id" value="{$query.card_id}" />
        {$lang.card_sn}:
        <input class="infoTableInput2" type="text" name="card_sn" value="{$query.card_sn}" />
        {$lang.valid}:
        <select class="querySelect" name="is_valid">
          <option value="">{$lang.select_all}</option>
          
                    {html_options options=$cfg_pointcard.is_valid selected=$query.is_valid}
                
        </select>
          {$lang.use_status}:
          <select class="querySelect" name="use_status">
              <option value="">{$lang.select_all}</option>

              {html_options options=$cfg_pointcard.use_status selected=$query.use_status}

          </select>
        {$lang.denomination}:
        <select class="querySelect" name="denomination">
          <option value="">{$lang.select_all}</option>
          
                    {html_options options=$cfg_pointcard.denomination selected=$query.denomination}
                
        </select>
          {$lang.batch_no}:
          <select class="querySelect" name="batch_no">
              <option value="">{$lang.select_all}</option>

              {html_options options=$batch_no_list selected=$query.batch_no}

          </select>
        {$lang.use_range}:
        <select class="querySelect" name="use_range">
          <option value="">{$lang.select_all}</option>
          
                    {html_options options=$cfg_pointcard.use_range selected=$query.use_range}
                
        </select>
        <input type="submit" class="formbtn" value="{$lang.query}" />
      </div>
      <!--{if $filtered}-->
      <a class="left formbtn1" href="index.php?app=pointcard">{$lang.cancel_query}</a>
      <!--{/if}-->
    </form>
  </div>
  <div class="fontr"> {if $pointcards}{include file=page.top.html}{/if} </div>
</div>
<div class="tdare">
  <table width="100%" cellspacing="0" class="dataTable">
    <!--{if $pointcards}-->
    <tr class="tatr1">
      <td width="20" class="firstCell"><input type="checkbox" class="checkall_s" /></td>
      <td><span ectype="order_by" fieldname="card_id">{$lang.goods_sn}</span></td>
      <td><span ectype="order_by" fieldname="card_sn">{$lang.card_sn}</span></td>
      <td><span ectype="order_by" fieldname="batch_no">{$lang.batch_no}</span></td>
      <td><span ectype="order_by" fieldname="denomination">{$lang.denomination}</span></td>
      <td><span ectype="order_by" fieldname="add_time">{$lang.add_time}</span></td>
      <td><span ectype="order_by" fieldname="effective_time">{$lang.effective_time}</span></td>
      <td><span ectype="order_by" fieldname="valid_time">{$lang.valid_time}</span></td>
      <td><span ectype="order_by" fieldname="effective_time">{$lang.use_time}</span></td>
      <td>{$lang.purpose}</td>
      <td>{$lang.use_range}</td>
      <td>{$lang.use_status}</td>
      <td>{$lang.is_valid}</td>
    </tr>
    <!--{/if}-->
    <!--{foreach from=$pointcards item=card}-->
    <tr class="tatr2">
      <td class="firstCell"><input type="checkbox" class="checkitem" value="{$card.card_id}" {if $card.use_status eq 1 or $card.is_valid eq 2}disabled="disabled"{/if} /></td>
      <td>{$card.card_id|escape}</td>
      <td>{$card.card_sn|escape}</td>
      <td>{$card.batch_no|escape}</td>
      <td>{$card.denomination}</td>
      <td>{$card.add_time|date}</td>
      <td><!--{if $card.effective_time}-->
        {$card.effective_time|date}
        <!--{else}-->
        --
        <!--{/if}--></td>
      <td>{$card.valid_time|date}</td>
      <td><!--{if $card.use_time}-->
        {$card.use_time|date}
        <!--{else}-->
        --
        <!--{/if}--></td>
      <td>{$cfg_pointcard.purpose.$card.purpose|escape}</td>
      <td>{$cfg_pointcard.use_range.$card.use_range|escape}</td>
      <td>{$cfg_pointcard.use_status.$card.use_status|escape}</td>
      <td>{$cfg_pointcard.valid.$card.is_valid|escape}</td>
      
    </tr>
    <!--{foreachelse}-->
    <tr class="no_data">
      <td colspan="10">{$lang.no_data}</td>
    </tr>
    <!--{/foreach}-->
  </table>
  <!--{if $pointcards}-->
  <div id="dataFuncs">
    <div id="batchAction" class="left paddingT15"> &nbsp;&nbsp;
      <input class="formbtn batchButton_s" type="button" value="{$lang.affirm_valid}" name="id" uri="index.php?app=pointcard&act=edit&is_valid=1" presubmit="confirm('{$lang.confirm_valid}');" />&nbsp;&nbsp;&nbsp;
      <input class="formbtn batchButton_s" type="button" value="{$lang.affirm_no_valid}" name="id" uri="index.php?app=pointcard&act=edit&is_valid=2" presubmit="confirm('{$lang.confirm_no_valid}');" />
      <input class="formbtn1 batchButton_s" type="button" value="{$lang.affirm_valid_time}" id="sub_valid_time" name="id" uri="index.php?app=pointcard&act=edit" presubmit="confirm('{$lang.confirm_valid_time}');" />&nbsp;
      <input class="queryInput pick_date" type="text" value="" readonly="readonly"  id="valid_time" name="valid_time" />
    </div>
    <div class="pageLinks">{include file=page.bottom.html}</div>
    <div class="clear"></div>
  </div>
  <!--{/if}-->
</div>
{include file="footer.html"} 